public class DecorativeDesignMode {
    /*
    装饰设计模式：Decorative design mode

    优点：耦合性不强，被装饰的类的变化与装饰类的变化无关
     */
    public static void main(String[] args) {
        SuperStudent superStudent = new SuperStudent(new Student());
        superStudent.code();
    }
}

interface Coder {
    void code();
}
class Student implements Coder {

    @Override
    public void code() {
        System.out.println("学会了javaSE");
        System.out.println("学会了javaWeb");
    }
}

class SuperStudent implements Coder {
    //获取被装饰类的引用
    private Student s;

    //在构造方法中传入被装饰类的对象
    public SuperStudent(Student s) {
        this.s = s;
    }

    //对原有的功能进行升级
    @Override
    public void code() {
        //调用Student类中具备的code()方法
        s.code();
        //增加更加强大的功能
        System.out.println("ssh");
        System.out.println("数据库");
        System.out.println("大数据");
        System.out.println("找月薪过万的工作");

    }
}